﻿using Spring.Context;
using Spring.Context.Support;

namespace Landpy.CruiseControlNet.Infrastructure.Ioc
{
    public class IOC
    {
        private static IOC iocContext;
        private static readonly object LockOjbect = new object();

        public IApplicationContext ApplicationContext { get; private set; }

        private IOC()
        {
            this.ApplicationContext = new XmlApplicationContext("IOC.xml");
        }

        public static IOC GetInstance()
        {
            lock (LockOjbect)
            {
                if (iocContext == null)
                {
                    lock (LockOjbect)
                    {
                        iocContext = new IOC();
                    }
                }
            }
            return iocContext;
        }

        public void Dispose()
        {
            this.ApplicationContext.Dispose();
        }
    }
}
